Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "scitems.hxx"
30 : :
31 : : #include <editeng/eeitem.hxx>
32 : :
33 : : #include <xmloff/XMLFontAutoStylePool.hxx>
34 : : #include <editeng/fontitem.hxx>
35 : : #include <editeng/editeng.hxx>
36 : : #include "document.hxx"
37 : : #include "docpool.hxx"
38 : : #include "xmlexprt.hxx"
39 : : #include "stlpool.hxx"
40 : : #include "attrib.hxx"
41 : :
42 [ - + ]: 16 : class ScXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
43 : : {
44 : : void AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults);
45 : : public:
46 : :
47 : : ScXMLFontAutoStylePool_Impl( ScXMLExport& rExport );
48 : :
49 : : };
50 : :
51 : 208 : void ScXMLFontAutoStylePool_Impl::AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults)
52 : : {
53 : : const SfxPoolItem* pItem;
54 [ + + ]: 832 : for( sal_uInt16 i=0; i < nIdCount; ++i )
55 : : {
56 : 624 : sal_uInt16 nWhichId(pWhichIds[i]);
57 [ + + ][ + - ]: 624 : if (bExportDefaults && (0 != (pItem = &pItemPool->GetDefaultItem(nWhichId))))
[ + + ]
58 : : {
59 : 24 : const SvxFontItem *pFont((const SvxFontItem *)pItem);
60 : 48 : Add( pFont->GetFamilyName(), pFont->GetStyleName(),
61 : 24 : sal::static_int_cast<sal_Int16>(pFont->GetFamily()),
62 : 24 : sal::static_int_cast<sal_Int16>(pFont->GetPitch()),
63 [ + - ][ + - ]: 72 : pFont->GetCharSet() );
64 : : }
65 : 624 : sal_uInt32 nItems(pItemPool->GetItemCount2( nWhichId ));
66 [ + + ]: 640 : for( sal_uInt32 j = 0; j < nItems; ++j )
67 : : {
68 [ + - ]: 16 : if( 0 != (pItem = pItemPool->GetItem2( nWhichId, j ) ) )
69 : : {
70 : 16 : const SvxFontItem *pFont((const SvxFontItem *)pItem);
71 : 32 : Add( pFont->GetFamilyName(), pFont->GetStyleName(),
72 : 16 : sal::static_int_cast<sal_Int16>(pFont->GetFamily()),
73 : 16 : sal::static_int_cast<sal_Int16>(pFont->GetPitch()),
74 [ + - ][ + - ]: 48 : pFont->GetCharSet() );
75 : : }
76 : : }
77 : : }
78 : 208 : }
79 : :
80 : 8 : ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(
81 : : ScXMLExport& rExportP ) :
82 : 8 : XMLFontAutoStylePool( rExportP )
83 : : {
84 : : sal_uInt16 aWhichIds[3] = { ATTR_FONT, ATTR_CJK_FONT,
85 : 8 : ATTR_CTL_FONT };
86 : : sal_uInt16 aEditWhichIds[3] = { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK,
87 : 8 : EE_CHAR_FONTINFO_CTL };
88 : : sal_uInt16 aPageWhichIds[4] = { ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERLEFT,
89 : 8 : ATTR_PAGE_HEADERRIGHT, ATTR_PAGE_FOOTERRIGHT };
90 : :
91 [ + - ][ + - ]: 8 : const SfxItemPool* pItemPool(rExportP.GetDocument() ? rExportP.GetDocument()->GetPool() : NULL);
92 [ + - ]: 8 : AddFontItems(aWhichIds, 3, pItemPool, sal_True);
93 [ + - ]: 8 : const SfxItemPool* pEditPool(rExportP.GetDocument()->GetEditPool());
94 [ + - ]: 8 : AddFontItems(aEditWhichIds, 3, pEditPool, false);
95 : :
96 [ + - ][ + - ]: 8 : SfxStyleSheetIterator* pItr(rExportP.GetDocument() ? rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF) : NULL);
[ + - ]
97 [ + - ]: 8 : if(pItr)
98 : : {
99 [ + - ]: 8 : SfxStyleSheetBase* pStyle(pItr->First());
100 [ + - ]: 8 : SfxItemPool* pPageEditPool(EditEngine::CreatePool());
101 [ + - ]: 8 : EditEngine aEditEngine(pPageEditPool);
102 [ + + ]: 24 : while (pStyle)
103 : : {
104 [ + - ]: 16 : const SfxItemPool& rPagePool(pStyle->GetPool().GetPool());
105 [ + + ]: 80 : for (sal_uInt8 j = 0; j < 4; ++j)
106 : : {
107 : 64 : sal_uInt16 nPageWhichId(aPageWhichIds[j]);
108 [ + - ]: 64 : sal_uInt32 nPageHFItems(rPagePool.GetItemCount2(nPageWhichId));
109 : : const ScPageHFItem* pPageItem;
110 [ + + ]: 152 : for (sal_uInt32 k = 0; k < nPageHFItems; ++k)
111 : : {
112 [ + - ][ + + ]: 88 : if (0 != (pPageItem = static_cast<const ScPageHFItem*>(rPagePool.GetItem2(nPageWhichId, k))))
113 : : {
114 : 64 : const EditTextObject* pLeftArea(pPageItem->GetLeftArea());
115 [ + - ]: 64 : if (pLeftArea)
116 : : {
117 [ + - ]: 64 : aEditEngine.SetText(*pLeftArea);
118 [ + - ]: 64 : AddFontItems(aEditWhichIds, 3, pPageEditPool, false);
119 : : }
120 : 64 : const EditTextObject* pCenterArea(pPageItem->GetCenterArea());
121 [ + - ]: 64 : if (pCenterArea)
122 : : {
123 [ + - ]: 64 : aEditEngine.SetText(*pCenterArea);
124 [ + - ]: 64 : AddFontItems(aEditWhichIds, 3, pPageEditPool, false);
125 : : }
126 : 64 : const EditTextObject* pRightArea(pPageItem->GetRightArea());
127 [ + - ]: 64 : if (pRightArea)
128 : : {
129 [ + - ]: 64 : aEditEngine.SetText(*pRightArea);
130 [ + - ]: 64 : AddFontItems(aEditWhichIds, 3, pPageEditPool, false);
131 : : }
132 : : }
133 : : }
134 : : }
135 [ + - ]: 16 : pStyle = pItr->Next();
136 [ + - ]: 8 : }
137 : : }
138 : 8 : }
139 : :
140 : :
141 : 8 : XMLFontAutoStylePool* ScXMLExport::CreateFontAutoStylePool()
142 : : {
143 [ + - ]: 8 : return new ScXMLFontAutoStylePool_Impl( *this );
144 : : }
145 : :
146 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|