1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
22 #include <com/sun/star/util/XRefreshable.hpp>
25 #include <unoprnms.hxx>
27 using namespace ::com::sun::star
;
28 using namespace ::com::sun::star::lang
;
29 using namespace ::com::sun::star::container
;
30 using namespace ::com::sun::star::uno
;
32 void SwLabDlg::UpdateFieldInformation(uno::Reference
< frame::XModel
> const & xModel
, const SwLabItem
& rItem
)
34 uno::Reference
< text::XTextFieldsSupplier
> xFields(xModel
, uno::UNO_QUERY
);
35 uno::Reference
< container::XNameAccess
> xFieldMasters
= xFields
->getTextFieldMasters();
37 static const struct SwLabItemMap
{
39 OUString
SwLabItem::*pValue
;
41 { "BC_PRIV_FIRSTNAME" , &SwLabItem::m_aPrivFirstName
},
42 { "BC_PRIV_NAME" , &SwLabItem::m_aPrivName
},
43 { "BC_PRIV_INITIALS" , &SwLabItem::m_aPrivShortCut
},
44 { "BC_PRIV_FIRSTNAME_2", &SwLabItem::m_aPrivFirstName2
},
45 { "BC_PRIV_NAME_2" , &SwLabItem::m_aPrivName2
},
46 { "BC_PRIV_INITIALS_2" , &SwLabItem::m_aPrivShortCut2
},
47 { "BC_PRIV_STREET" , &SwLabItem::m_aPrivStreet
},
48 { "BC_PRIV_ZIP" , &SwLabItem::m_aPrivZip
},
49 { "BC_PRIV_CITY" , &SwLabItem::m_aPrivCity
},
50 { "BC_PRIV_COUNTRY" , &SwLabItem::m_aPrivCountry
},
51 { "BC_PRIV_STATE" , &SwLabItem::m_aPrivState
},
52 { "BC_PRIV_TITLE" , &SwLabItem::m_aPrivTitle
},
53 { "BC_PRIV_PROFESSION" , &SwLabItem::m_aPrivProfession
},
54 { "BC_PRIV_PHONE" , &SwLabItem::m_aPrivPhone
},
55 { "BC_PRIV_MOBILE" , &SwLabItem::m_aPrivMobile
},
56 { "BC_PRIV_FAX" , &SwLabItem::m_aPrivFax
},
57 { "BC_PRIV_WWW" , &SwLabItem::m_aPrivWWW
},
58 { "BC_PRIV_MAIL" , &SwLabItem::m_aPrivMail
},
59 { "BC_COMP_COMPANY" , &SwLabItem::m_aCompCompany
},
60 { "BC_COMP_COMPANYEXT" , &SwLabItem::m_aCompCompanyExt
},
61 { "BC_COMP_SLOGAN" , &SwLabItem::m_aCompSlogan
},
62 { "BC_COMP_STREET" , &SwLabItem::m_aCompStreet
},
63 { "BC_COMP_ZIP" , &SwLabItem::m_aCompZip
},
64 { "BC_COMP_CITY" , &SwLabItem::m_aCompCity
},
65 { "BC_COMP_COUNTRY" , &SwLabItem::m_aCompCountry
},
66 { "BC_COMP_STATE" , &SwLabItem::m_aCompState
},
67 { "BC_COMP_POSITION" , &SwLabItem::m_aCompPosition
},
68 { "BC_COMP_PHONE" , &SwLabItem::m_aCompPhone
},
69 { "BC_COMP_MOBILE" , &SwLabItem::m_aCompMobile
},
70 { "BC_COMP_FAX" , &SwLabItem::m_aCompFax
},
71 { "BC_COMP_WWW" , &SwLabItem::m_aCompWWW
},
72 { "BC_COMP_MAIL" , &SwLabItem::m_aCompMail
},
78 for( const SwLabItemMap
* p
= aArr
; p
->pName
; ++p
)
81 "com.sun.star.text.FieldMaster.User."
82 + OUString::createFromAscii(p
->pName
));
83 if( xFieldMasters
->hasByName( uFieldName
))
85 uno::Any aFirstName
= xFieldMasters
->getByName( uFieldName
);
86 uno::Reference
< beans::XPropertySet
> xField
;
87 aFirstName
>>= xField
;
89 aContent
<<= rItem
.*p
->pValue
;
90 xField
->setPropertyValue( UNO_NAME_CONTENT
, aContent
);
94 catch (const uno::RuntimeException
&)
99 uno::Reference
< container::XEnumerationAccess
> xFieldAcc
= xFields
->getTextFields();
100 uno::Reference
< util::XRefreshable
> xRefresh(xFieldAcc
, uno::UNO_QUERY
);
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */