summaryrefslogtreecommitdiff
path: root/sw/source/filter/docx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-05-09 11:56:35 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2017-05-10 11:17:09 +0200
commita470d16208a78ae6893d199b3b6bc77a8559b06a (patch)
treebdfd6070cb742be3d4bda7204c8fe731ecace202 /sw/source/filter/docx
parent4c0fb07f342d4bd0101fd5764f101f0adfc3001e (diff)
AutoText: add only real AutoText entries
* add only autoTxT gallery type * new test with other types of entries Change-Id: Ibf7751c73dcf3b6ebd69eec5f4931dbeaaf098c8 Reviewed-on: https://gerrit.libreoffice.org/37425 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/source/filter/docx')
-rw-r--r--sw/source/filter/docx/swdocxreader.cxx54
1 files changed, 32 insertions, 22 deletions
diff --git a/sw/source/filter/docx/swdocxreader.cxx b/sw/source/filter/docx/swdocxreader.cxx
index b72253c0b57a..501b0e567a18 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -38,6 +38,8 @@
#include <unotxdoc.hxx>
#include <unotools/streamwrap.hxx>
+#define AUTOTEXT_GALLERY "autoTxt"
+
using namespace css;
extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOCX()
@@ -103,6 +105,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
SwNodeIndex aDocEnd( pD->GetNodes().GetEndOfContent() );
SwNodeIndex aStart( *aDocEnd.GetNode().StartOfSectionNode(), 1 );
+ bool bIsAutoText = false;
if( aStart < aDocEnd && ( aDocEnd.GetIndex() - aStart.GetIndex() > 2 ) )
{
@@ -118,6 +121,10 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
++rIdx;
aLNm = aPam.GetNode().GetTextNode()->GetText();
+
+ // is AutoText?
+ bIsAutoText = aLNm.startsWith(AUTOTEXT_GALLERY);
+ aLNm = aLNm.copy(strlen(AUTOTEXT_GALLERY) + 1);
}
// Do not copy name
@@ -153,32 +160,35 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
}
aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
- // Now we have the right selection for one entry
- rBlocks.ClearDoc();
+ if( bIsAutoText )
+ {
+ // Now we have the right selection for one entry
+ rBlocks.ClearDoc();
- OUString sShortcut = aLNm;
+ OUString sShortcut = aLNm;
- // Need to check make sure the shortcut is not already being used
- sal_Int32 nStart = 0;
- sal_uInt16 nCurPos = rBlocks.GetIndex( sShortcut );
- sal_Int32 nLen = sShortcut.getLength();
+ // Need to check make sure the shortcut is not already being used
+ sal_Int32 nStart = 0;
+ sal_uInt16 nCurPos = rBlocks.GetIndex( sShortcut );
+ sal_Int32 nLen = sShortcut.getLength();
- while( (sal_uInt16)-1 != nCurPos )
- {
- sShortcut = sShortcut.copy( 0, nLen );
- // add an Number to it
- sShortcut += OUString::number( ++nStart );
- nCurPos = rBlocks.GetIndex( sShortcut );
- }
+ while( (sal_uInt16)-1 != nCurPos )
+ {
+ sShortcut = sShortcut.copy( 0, nLen );
+ // add an Number to it
+ sShortcut += OUString::number( ++nStart );
+ nCurPos = rBlocks.GetIndex( sShortcut );
+ }
- if( rBlocks.BeginPutDoc( sShortcut, sShortcut ) )
- {
- SwDoc* pGlDoc = rBlocks.GetDoc();
- SwNodeIndex aIdx( pGlDoc->GetNodes().GetEndOfContent(), -1 );
- pCNd = aIdx.GetNode().GetContentNode();
- SwPosition aPos( aIdx, SwIndex( pCNd, ( pCNd ) ? pCNd->Len() : 0 ) );
- pD->getIDocumentContentOperations().CopyRange( aPam, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true );
- rBlocks.PutDoc();
+ if( rBlocks.BeginPutDoc( sShortcut, sShortcut ) )
+ {
+ SwDoc* pGlDoc = rBlocks.GetDoc();
+ SwNodeIndex aIdx( pGlDoc->GetNodes().GetEndOfContent(), -1 );
+ pCNd = aIdx.GetNode().GetContentNode();
+ SwPosition aPos( aIdx, SwIndex( pCNd, ( pCNd ) ? pCNd->Len() : 0 ) );
+ pD->getIDocumentContentOperations().CopyRange( aPam, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true );
+ rBlocks.PutDoc();
+ }
}
aStart = aStart.GetNode().EndOfSectionIndex() + 1;